<template>
    <el-dialog
            :visible.sync="newWorkflowDialogVisible"
            title="运行任务基本信息填写"
            width="30%"
            @close="reset"
            :close-on-click-modal="false"
            v-dialogDrag>
        <el-form :rules="rules" ref="Form" :model="Form">
            <el-form-item prop="fileName">
                <el-input v-model="Form.fileName" placeholder="请输入任务名称"></el-input>
            </el-form-item>
            <el-form-item prop="fileDescription">
                <el-input v-model="Form.fileDescription" placeholder="请输入任务描述"></el-input>
            </el-form-item>
        </el-form>
        <div style="margin-top: 20px;text-align: center">
            <el-button type="primary" @click="submit">确定</el-button>
            <el-button @click="newWorkflowDialogVisible=false">取消</el-button>
        </div>
    </el-dialog>
</template>

<script>

    export default {
        name: "newFolderDialog",
        props: ['currentPath'],
        data() {
            return {
                Form: {
                    param: {},
                    fileName: "",
                    fileDescription:""
                },
                newWorkflowDialogVisible: false,
                rules: {
                    fileName: [{required: true, message: '请输入任务名称', trigger: 'blur'}],
                },
            }
        },
        methods: {
            submit() {
                let that = this;
                this.$refs["Form"].validate((valid) => {
                    if (valid) {
                        let that=this;
                        let data={
                            "fileName":that.Form.fileName,
                            "fileDescription":that.Form.fileDescription
                        }
                        that.$Bus.$emit("newWorkflowName",data);
                        that.newWorkflowDialogVisible = false;
                    } else {
                        that.$message({
                            message: '请确认填写正确参数',
                            type: 'warning'
                        });
                        console.log('error submit!!');
                        return false;
                    }
                })

            },
            reset() {
                // this.Form.fileName='';
                this.$refs["Form"].resetFields();
            }
        },
        created() {
            let that = this;
            this.$Bus.$on("newWorkflowDialog", res => {
                that.newWorkflowDialogVisible = true;
            })

        },
    }
</script>

<style>

</style>